package main

import (
	"context"
	"demo-grpc/pb"
	"fmt"
	"log"

	"google.golang.org/grpc"
)

func main() {

	serverAddr := "127.0.0.1:8080"
	// var opts []grpc.DialOption

	conn, err := grpc.Dial(serverAddr, grpc.WithInsecure())
	if err != nil {
		log.Fatalf("fail to dial: %v", err)
	}

	defer conn.Close()
	client := pb.NewUserInfoServiceClient(conn)

	req := new(pb.UserRequest)
	req.Name = "User_Info"

	resp, err := client.GetUserInfo(context.Background(), req)

	if err != nil {
		fmt.Printf("GetUserInfo err %v", err)
	}
	fmt.Printf("UserInfo        %v \n", resp.Name)

	req2 := &pb.TaskRequest{
		Name: "Task",
	}

	resp, err = client.GetTaskInfo(context.Background(), req2)
	if err != nil {
		fmt.Printf("GetTaskInfo err %v", err)
	}
	fmt.Printf("TaskInfo        %v \n", resp.Name)
}
